package com.expert.conrtoller;
import com.expert.annotations.RoleAnnotation;
import com.expert.dto.ExtractAvoidInfoDTO;
import com.expert.enums.RoleLevel;
import com.expert.result.Result;
import com.expert.service.ExtractAvoidService;
import com.expert.vo.ExtractAvoidInitVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: ExtractAvoidController
 * @Author: cxs
 * @Date: 2024/03/22 13:31
 * @Description:
 **/
@RestController
@RequestMapping("/avoid")
@Slf4j
public class ExtractAvoidController {

    @Autowired
    ExtractAvoidService extractAvoidService;

    /**
     * 初始化回避条件的信息
     * @param id
     * @return
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @GetMapping("/initAvoid/{id}")
    public Result<ExtractAvoidInitVo> initAvoid(@PathVariable("id") Long id){
      log.info("初始化回避条件信息，{}",id);
        ExtractAvoidInitVo extractAvoidInitVo=this.extractAvoidService.initAvoid(id);
        return Result.success(extractAvoidInitVo);
    }

    /**
     * 添加回避条件信息
     * @param extractAvoidInfoDTO
     * @return
     */
    @RoleAnnotation(level = RoleLevel.ADMIN)
    @PostMapping("/addAvoid")
    public Result addAddAvoid(@RequestBody ExtractAvoidInfoDTO extractAvoidInfoDTO){
        log.info("添加回避添加信息");
        this.extractAvoidService.addAvoid(extractAvoidInfoDTO);
        return Result.success();
    }
}
